package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Region;
import cn.wolfcode.trip.base.mapper.RegionMapper;
import cn.wolfcode.trip.base.service.IRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RegionServiceImpl implements IRegionService {
    @Autowired
    private RegionMapper regionMapper;

    @Override
    public List<Region> selectByParentId(Long parentId) {
        List<Region> list = regionMapper.selectByParentId(parentId);
        return list;
    }

    @Override
    public void saveOrUpdate(Region region) {
        if (region.getId() == null) {
            regionMapper.insert(region);
        } else {
            regionMapper.updateByPrimaryKey(region);
        }
    }

    @Override
    public void updateState(Long id,Long  state) {
        regionMapper.updateState(id,state);
    }
    @Override
    public List<Region> listAll(Integer state) {
        return regionMapper.selectAll(state);
    }
}
